Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the Xamarin.Mac.NET / xamarinmacnet TFM #2572

Closed
wants to merge 4 commits into from

Conversation

mattleibow
Copy link

Bug

Fixes: NuGet/Home#2662
Regression: No

Fix

Details: This PR adds the existing "Xamarin.Mac.NET" TFM to the set that NuGet actually supports.

More details of the TFM can be found here: https://docs.microsoft.com/en-us/xamarin/mac/platform/target-framework. But, the gist of the framework is:

A very similar subset to the “desktop” BCL, with a few small removals. As the Target Framework is almost identical to net45 (and later), it can easily consume many nugets that do not provide either netstandard2 or specific Xamarin.Mac builds.

The need for this specific TFM is not to actually just create another library for a NuGet package (which totally is a use case for some libraries), but also for the case where the consumer app is the full framework, but needs to use the Xamarin.Mac TFM over the .NETFramework. See this issue: mono/SkiaSharp#736

There has been a bit of discussion, but never actually went anywhere. The original issue has had 2 PRs, one against NuGet2 and one against NuGet.Core but the discussion stopped.

Adding a few of the original participants to start the discussion again: @mrward @ghuntley @chamons @joelverhagen @emgarten @mishra14 @onovotny @mhutch

Testing/Validation

Tests Added: Yes
Validation done:

@nkolev92
Copy link
Member

nkolev92 commented Dec 18, 2018

Going through the original thread, my instinct is this is not right because xamarinmacnet45 and net45 are not fully compatible.
AssetTargetFallback would be the way to go here.

See https://github.com/NuGet/Home/wiki/Enable-.NET-Core-2.0-projects-to-work-with-.NET-Framework-4.6.1-compatible-packages.
//cc @rrelyea

@mrward
Copy link
Member

mrward commented Dec 18, 2018

Does PackageTargetFallback and AssetTargetFallback work with projects that use packages.config? I thought it was only for projects that use PackageReferences.

@nkolev92
Copy link
Member

It's only PackageReference.

@mattleibow
Copy link
Author

I created a test app and I tried both PackageTargetFallback and AssetTargetFallback with PackageReference, but it still went for the net45 assembly, even if there is a specific Xamarin.Mac20 assembly.

FullFrameworkMacApp.zip

@mrward
Copy link
Member

mrward commented Dec 21, 2018

They are fallback target frameworks so they are only used if nothing in the NuGet package matches the project's target framework. The project in the .zip, from NuGet's point of view, has a target framework of .NET Framework 4.7.2 so if the NuGet package has .NET Framework assemblies then those will be used.

@mattleibow
Copy link
Author

Isn't that why we have this PR? To OVERRIDE the behavior of this particular TFM?

@mrward
Copy link
Member

mrward commented Dec 21, 2018

The PR is to add support into NuGet for a new Xamarin.Mac.Net target framework, and to allow this target framework to support both Xamarin.Mac and .NET Framework assemblies as well as assemblies that explicitly target Xamarin.Mac.Net. However this target framework does not exist yet - work is required on the Xamarin.Mac side to define and support it. As of today a Xamarin.Mac Full project has a .NETFramework target framework.

@nkolev92
Copy link
Member

The PR is to add support into NuGet for a new Xamarin.Mac.Net target framework, and to allow this target framework to support both Xamarin.Mac and .NET Framework assemblies as well as assemblies that explicitly target Xamarin.Mac.Net. However this target framework does not exist yet - work is required on the Xamarin.Mac side to define and support it. As of today a Xamarin.Mac Full project has a .NETFramework target framework.

Based on the above comment, this is not something that NuGet can solve on it's own.

Can the discussion continue on xamarin side and then loop back if/when ready.

Similar to the earlier discussions/PR, I don't see this being merged in this state.

Thoughts @mrward @rrelyea @anangaur @jainaashish ?

@mrward
Copy link
Member

mrward commented Jan 23, 2019

/cc @chamons

@chamons
Copy link

chamons commented Jan 25, 2019

I've talked to @mrward and I believe xamarin/xamarin-macios#5480 describes the work needed on our end. In theory it could be a one-liner in our props file, but I have concerns on the secondary consequences \ regressions such a change might cause.

In any case, the soonest such a change could ship at the earliest would be d16-1, so months away. I'll try to get a prototype out soon for testing, but even if lands today in master it'd be awhile. Would that block this PR?

@nkolev92
Copy link
Member

@chamons

I'd imagine we want both work items to go live simultaneously.

//cc @rrelyea for visibility.

@ghuntley
Copy link

ghuntley commented Feb 7, 2019

Dropping in to say it's cool that you have picked this back up again

@chamons
Copy link

chamons commented Feb 8, 2019

So we haven't had time on the Xamarin.Mac side to implement this yet, but this morning (instead of sleeping apparently), I had an idea on a way we could get this done sooner.

I wrote it up here but the short version is that we should feature flag this so projects can opt-in a release earlier so we can test this out in the wild first.

chamons added a commit to xamarin/xamarin-macios that referenced this pull request Feb 21, 2019
…c.NET (opt-in)

- #5480
- Related: NuGet/NuGet.Client#2572

To allow nuget to target XM Full we need to have a unique TFI (TargetFrameworkIdentifier).

However, that's a really scary change to force, so let's opt-in for now. You can set

<MigrateToNewXMTFI>true</MigrateToNewXMTFI> in your project or

MigrateToNewXMTFI=true msbuild project.csproj

to try it out. We can convert the opt-in to an opt-out with sufficient validation \ releases.
@chamons
Copy link

chamons commented Feb 21, 2019

I have a PR implementation for what I think we need:

xamarin/xamarin-macios#5654

I'll post a package shortly once it builds, but:

<MigrateToNewXMTFI>true</MigrateToNewXMTFI>
or
MigrateToNewXMTFI=true msbuild project.csproj

should do what we expect, hopefully.

Feedback, 👀 's on the PR, and thoughts welcome.

chamons added a commit to xamarin/xamarin-macios that referenced this pull request Feb 28, 2019
…c.NET (opt-in) (#5654)

- #5480
- Related: NuGet/NuGet.Client#2572

To allow nuget to target XM Full we need to have a unique TFI (TargetFrameworkIdentifier).

However, that's a really scary change to force, so let's opt-in for now. You can set

<MigrateToNewXMIdentifier>true</MigrateToNewXMIdentifier> in your project or

MigrateToNewXMIdentifier=true msbuild project.csproj

to try it out. We can convert the opt-in to an opt-out with sufficient validation \ releases.
@chamons
Copy link

chamons commented Mar 1, 2019

Xamarin.Mac now contains a MigrateToNewXMIdentifier option that you can read about here. Please use that to test this and tell me if it solves this use case.

You can download the package here.

This looks to make our next major release as opt-in if no one here raises any objections. We can get some testing and consider making it opt-out later if that goes well.

@Odirb
Copy link

Odirb commented Jul 23, 2019

@chamons
My issue on SkiaSharp seems to be related to this problem : mono/SkiaSharp#913 (comment).

I have tried to install you package (on a Visual Studio for Mac 8.1.5 build 9), but when I add the MigrateToNewXMIdentifier in my csproj my project didn't load anymore. Studio Ide logs contains this stack trace

WARNING [2019-07-23 08:48:19Z]: Unknown TargetFramework 'Xamarin.Mac.NET,Version=v4.6' is being requested from SystemAssemblyService, returning empty TargetFramework WARNING [2019-07-23 08:48:19Z]: Unknown TargetFramework '.NETFramework,Version=v1.1' is being requested from SystemAssemblyService, returning empty TargetFramework ERROR [2019-07-23 08:48:19Z]: Error while trying to load the project /Users/christophe/Projects/TestSkia/FullMicMac/FullMicMac.csproj System.ArgumentException: Project does not support framework 'Xamarin.Mac.NET,Version=v4.6' at MonoDevelop.Projects.DotNetProject.set_TargetFramework (MonoDevelop.Core.Assemblies.TargetFramework value) [0x0008a] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs:419 at MonoDevelop.Projects.DotNetProject.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00106] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs:1972 at MonoDevelop.Projects.Project+DefaultMSBuildProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:4836 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.MonoMac.XamMac2ProjectFlavor.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.150.3/work/1/s/MonoDevelop.MonoMac/MonoDevelop.MonoMac/Project/XamMac2Project.cs:309 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.ProjectExtension.OnReadProjectHeader (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x00000] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:141 at MonoDevelop.Projects.Project.ReadProject (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) [0x0004d] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:2593 at MonoDevelop.Projects.Project.LoadAsync (MonoDevelop.Core.ProgressMonitor monitor) [0x000ed] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:437 at MonoDevelop.Projects.Project+<>c__DisplayClass68_0.<OnLoad>b__0 () [0x00028] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:418 at MonoDevelop.Projects.MSBuild.MSBuildProjectService.LoadItem (MonoDevelop.Core.ProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.MSBuild.MSBuildFileFormat expectedFormat, System.String typeGuid, System.String itemGuid, MonoDevelop.Projects.SolutionLoadContext ctx) [0x001f0] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs:405 at MonoDevelop.Projects.ProjectService+<>c__DisplayClass25_0.<ReadSolutionItem>b__0 () [0x00101] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs:126 at MonoDevelop.Core.Runtime+<>c__441[T].b__44_0 (System.Object state) [0x00046] in /Users/vsts/agent/2.153.2/work/1/s/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs:389
`
Do you have any idea?

@mrward
Copy link
Member

mrward commented Jul 23, 2019

@Odirb Visual Studio for Mac is not aware of the Xamarin.Mac.NET framework currently. Support for that would need to be added to Visual Studio for Mac.

@Odirb
Copy link

Odirb commented Jul 23, 2019

@mrward do you think this will be supported soon?

@mrward
Copy link
Member

mrward commented Jul 23, 2019

@Odirb The problem is being tracked internally but it has not been scheduled.

Whilst you could workaround the problem in Visual Studio for Mac by creating an extension which enabled the target framework the problem still remains that NuGet currently does not support this new framework. Which means you would still not be able to install a package that targets Xamarin.Mac.NET into a project in Visual Studio for Mac.

@Odirb
Copy link

Odirb commented Jul 24, 2019

Thanks @mrward for you answer. I will use an ugly workaround I have found to fix my initial issue, and wait the support for this new target framework.

@Phyyl
Copy link

Phyyl commented Nov 15, 2019

Any news on this PR? We are anxiously waiting on this to move forward

@zivkan zivkan added the Community PRs created by someone not in the NuGet team label Mar 5, 2020
@zivkan zivkan self-assigned this Mar 11, 2020
@zivkan
Copy link
Member

zivkan commented Mar 18, 2020

Given the current proposal for .NET 5 TFMs, the TFMs requested in this PR will not be required. If the .NET 5 TFM design proposal falls through and these TFMs are required again, we can re-open this PR.

@zivkan zivkan closed this Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PRs created by someone not in the NuGet team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Impossible to target Xamarin.Mac .NET 4.5 Framework
9 participants